import request from "@/utils/request";

/**
 * 获取所有成果
 */
export function getAllAchievement(type, currentPage, pageSize) {
    return request({
        url: '/achievement/getAllAchievement',
        method: 'post',
        data: {type, currentPage, pageSize}
    })
}

/**
 *  根据条件搜索成果
 */
export function searchAchievements(searchData, currentPage, pageSize) {
    return request({
        url: '/achievement/search',
        method: 'post',
        data: {
            ...searchData,
            currentPage,
            pageSize
        }
    })
}

/**
 *  根据等级搜索成果
 */
export function getAllAchievementByLevel(levels) {
    return request({
        url: '/achievement/level/all',
        method: 'post',
        data: {
            levels
        }
    })
}

/**
 * 下载附件
 */
export function exportFile(id) {
    return request({
        url: '/achievement/downloadZip',
        method: 'post',
        params: {
            'paId': id
        },
        responseType: 'blob',  // 表明返回服务器返回的数据类型，要加在请求头里面，否则识别不了文件流
    })
}

/**
 * 导出成果
 */
export function exportExcel(ids) {
    return request({
        url: '/achievement/exportExcelAll',
        method: 'post',
        data: ids,
        responseType: 'blob',  // 表明返回服务器返回的数据类型，要加在请求头里面，否则识别不了文件流
    })
}


/**
 * 新增成果
 */
export function importAchievement(formData) {
    return request({
        url: '/achievement/importAchievementAndFile',
        method: 'post',
        data: formData,
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}


/**
 * 根据工号获取姓名
 */
export function getAdvisorName(advisorID) {
    return request({
        url: '/achievement/getAdvisorName',
        method: 'get',
        params: {
            advisorID
        }
    })
}
